package com.tianruan.dc.modules.sys.user.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tianruan.dc.modules.sys.user.entity.db.UserDO;
import com.tianruan.dc.modules.sys.user.entity.dto.RegisterDTO;
import com.tianruan.dc.modules.sys.user.entity.dto.UserDTO;
import com.tianruan.dc.modules.sys.user.entity.vo.UserVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<UserDO> {


    UserDTO getUserPermissionByNo(@Param("username") String username);

    Integer getUserPermissionByRoleAndUsername(@Param("username") String username,
                                               @Param("roleName") String roleName);

    UserVO getUserRoleById(@Param("id") String id);


    IPage<UserVO> pageUser(Page page,
                           @Param("officeId") String officeId,
                           @Param("no") String no,
                           @Param("username")String username,
                           @Param("name")String name,
                           @Param("phone")String phone,
                           @Param("email")String email,
                           @Param("roleIdList") List<String> roleIdList);

    IPage<UserVO> pageStudent(Page page,
                              @Param("officeId") String officeId,
                              @Param("no") String no,
                              @Param("name")String name,
                              @Param("phone")String phone,
                              @Param("email")String email);

    Integer pageStudentCount(@Param("officeId") String officeId,
                                   @Param("no") String no,
                                   @Param("name")String name,
                                   @Param("phone")String phone,
                                   @Param("email")String email);

    List<UserVO> searchTeacherList(@Param("dtoEntity") UserDTO dtoEntity);

    IPage<UserVO> searchTeacher(IPage<UserDO> page,  @Param("dtoEntity") UserDTO dtoEntity);

    /**
     * 学生搜索学生
     * @param page
     * @param dtoEntity
     * @return
     */
    IPage<UserVO> searchStudentByStudent(IPage<UserDO> page,  @Param("dtoEntity") UserDTO dtoEntity);

    IPage<UserVO> findExpertList(IPage<UserDO> page, @Param("dtoEntity") UserDTO dtoEntity);

    IPage<UserVO> findDCExpertList(IPage<UserDO> page, @Param("dtoEntity") UserDTO dtoEntity);

    /**
     * 根据id获取密码
     * @param id
     * @return
     */
    String getPassword(@Param("id") String id);

    UserDTO getUserByPhone(@Param("phone") String phone);

    List<UserDTO> getUserByRoleId(@Param("roleId") String roleId);

    UserVO getStudentInfo(@Param("userId") String userId);

    List<UserVO> serachTeacher(@Param("ew") Wrapper<UserDO> queryWrapper);

    List<UserVO> serachStudent(@Param("ew") Wrapper<UserDO> queryWrapper);

    Long getStudentCount(@Param("officeId") String officeId, @Param("enrollmentYear") String enrollmentYear);

    /**
     * 根据用户名查询
     * @param username
     * @return
     */
    @Select("select * from t_sys_user where username = #{username}")
    UserDTO getByUsername(String username);


    /**
     * 根据用户名查询id
     * @param username
     * @return
     */
    @Select("select id from t_sys_user where username = #{username}")
    UserDTO getIdByUsername(String username);


}
